package com.king.io;

import com.google.common.base.Preconditions;
import com.google.common.io.Files;

import java.io.File;
import java.io.IOException;

import static java.lang.System.err;
/**
 * Created by Administrator on 2015/4/23.
 */
public class GuavaFile {
    public static void main(String[] args) {
        final  String fileName ="D:/写好的项目/b.txt";
        final  String content = "this is a content built by guava";
        Preconditions.checkNotNull(fileName, "file name is null");

        final File file  = new File(fileName);
        try {
            Files.write(content.getBytes(),file);

        }catch (IOException fileIoException){
            err.println("error trying to write to file"+fileName+fileIoException.toString());
        }
        System.out.println("guava创建b.txt完成");
    }
}
